const { rejects } = require("assert");
const fs = require("fs");
const { resolve } = require("path");
const path = "./wwwroot";
fs.readdir(path, (err, data) => {
  if (err) {
    console.log(err);
    return;
  }
  isDirect(data);
});
async function isDirect(data) {
  var dirArr = [];
  for (let i = 0; i < data.length; i++) {
    if (await promise(path + "/" + data[i])) {
      dirArr.push(data[i]);
    }
  }
  console.log(dirArr);
}
function promise(data) {
  return new Promise((resolve, reject) => {
    fs.stat(data, (err, data) => {
      if (err) {
        console.log("检查文件出错");
        return;
      }
      if (data.isDirectory()) {
        return resolve(true);
      } else {
        return resolve(false);
      }
    });
  });
}
